<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
		"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>typematic DOH Robot test</title>

	<style>
		@import "../../../util/doh/robot/robot.css";
	</style>

	<!-- required: dojo.js -->
	<script type="text/javascript" src="../../../dojo/dojo.js"></script>

	<script type="text/javascript">
		require([
			"doh/runner", "dojo/robotx",
			"dojo/dom", "dojo/keys",
			"dojo/domReady!"
		], function(doh, robot, dom, keys){
			robot.initRobot('../test_typematic.html');

			doh.register("press and hold test", [
				{
					name: "keyboard",
					timeout: 9000,
					runTest: function(){
						var
								d = new doh.Deferred(),
								input = dom.byId("typematicInput"),
								v;
						input.value = "";
						input.focus();

						robot.keyDown(keys.CTRL, 1000);
						robot.keyDown(keys.F11, 200);
						robot.sequence(function(){
							v = input.value; // get value before releasing key to reduce timing dependence on the robot
						}, 2000);
						robot.keyUp(keys.F11, 100);
						robot.keyUp(keys.CTRL, 100);

						robot.sequence(d.getTestCallback(function(){
							// allow off by 1
							doh.t(v == "aaaaaaaaaa" || v == "aaaaaaaaaaa" || v == "aaaaaaaaaaaa", "a letters typed " + v);
						}), 500);

						return d;
					}
				},
				{
					name: "mouse",
					timeout: 5000,
					runTest: function(){
						var
								d = new doh.Deferred(),
								input = dom.byId("typematicInput"),
								v;
						input.value = "";

						robot.mouseMoveAt("typematicButton", 500, 1);
						robot.mousePress({left: true}, 500);
						robot.sequence(function(){
							v = input.value; // get value before releasing button to reduce timing dependence on the robot
						}, 1000);
						robot.mouseRelease({left: true}, 100);

						robot.sequence(d.getTestCallback(function(){
							// allow off by 1
							doh.t(v == "bbbbbb" || v == "bbbbbbb" || v == "bbbbbbbb", "b letters typed " + v);
						}), 500);

						return d;
					}
				},
				{
					name: "double click",
					timeout: 5000,
					runTest: function(){
						var
								d = new doh.Deferred(),
								input = dom.byId("typematicInput");
						input.value = "";

						robot.mouseMoveAt("typematicButton", 500, 1);
						robot.mousePress({left: true}, 500);
						robot.mouseRelease({left: true}, 100);
						robot.mousePress({left: true}, 100);
						robot.mouseRelease({left: true}, 100);

						robot.sequence(d.getTestCallback(function(){
							doh.is("bb", input.value, "b letters typed " + input.value);
						}), 500);

						return d;
					}
				}
			]);

			doh.run();
		});
	</script>
</head>
</html>
